package com.example.android.utils.livedata

import androidx.lifecycle.LiveData
import retrofit2.Call
import retrofit2.CallAdapter
import java.lang.reflect.Type


class LiveDataCallAdapter<T>(mResponseType: Type) : CallAdapter<T, LiveData<T>?> {
    private val mResponseType: Type

    // 用于返回从GSON数据到JAVA对象的的类型
    override fun responseType(): Type {
        return mResponseType
    }

    override fun adapt(call: Call<T>): LiveData<T> {
        return MyLiveData(call)
    }

    init {
        this.mResponseType = mResponseType
    }
}